$(function () {
    //轮播图
    var mySwiper = new Swiper('.swiper', {
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        }, loop: true, autoplay: true, pagination: {
            el: '.swiper-pagination',
        },

    })
    const params = new URLSearchParams(this.location.search)
    const wd = params.get('wd')
    $.get('http://127.0.0.1:3000/v1/index/Recommended_today', data => {
        console.log(data)
        $('.main .first .detail>ul').html(
            data.data.map(value => {
                const { pic, type_of, title, rname, view_num } = value
                return `
                
                    <li>
                        <div class='img'><img src="${pic}" alt="">
                            <a href="">${type_of}</a>
                        </div>
                        <div class="text">
                            <p>${title}</p>
                            <div><span>${rname}</span>
                            <span>${view_num}</span>
                            </div>
                        </div>
                    </li>
                
            `
            })
        )


    })
    $.get('http://127.0.0.1:3000/v1/index/qy_mall', data => {
        $('.main .second >ul').html(
            data.data.map(value => {
                const { pic, title, pattern, price } = value
                return `
            <li>
                    <div class='img'><img src="${pic}" alt=""></div>
                    <div class="text">
                        <p class='line-2'>${title}</p>
                        <span>${pattern}</span>
                        <div class="price">￥<em>${price}</em>元起</div>
                    </div>
                </li>
            `
            })
        )
    })

    $.get('http://127.0.0.1:3000/v1/index/pop_notes', data => {
        $('.main .third>ul').html(
            data.data.map(value => {
                const { pic, comment, portrait, id, detail } = value
                return `
            <li>
                    <div class='img'>
                        <img src="${pic}" alt="">
                        <em>精华</em>
                        <div><i class='icon-huifu iconfont'></i>${comment}</div>
                    </div>
                    <div class='bottom'><div class="user"><img src="${portrait}" alt=""><span>${id}</span></div>
                    <div class="text line-2">${detail}</div></div>
                    
                </li>
            `
            })
        )
    })
    $.get('http://127.0.0.1:3000/v1/index/biu', data => {
        $('.main .fifth>ul').html(
            data.data.map(value => {
                const { pic, detail } = value
                return `
            <li>
                    <img src="${pic}" alt="">
                    <div>
                        <span class='line-5'>${detail}</span>
                        <div></div>
                        
                    </div>
            </li>
            `
            })

        )
    })
})